luci-base: fix button handling for named sections
authorFlorian Eckert <[email protected]>
Mon, 12 Dec 2022 13:58:38 +0000 (14:58 +0100)
committerFlorian Eckert <[email protected]>
Tue, 13 Dec 2022 12:32:50 +0000 (13:32 +0100)
If more than one named section is added to the page, it is currently the
case, that the first button is always switched on or off during input
validation of the uci section name. This is because the usage of the
'document.querySelector' function is to imprecise. Changing the search
start to the element to be created, fixes this.

Signed-off-by: Florian Eckert <[email protected]>
modules/luci-base/htdocs/luci-static/resources/form.js

index 2d540420bca5f53e1a933c697896e5170661636d..3c538b88ca2e6e2a2fe46cff5380889e99144c8d 100644 (file)
@@ -2259,7 +2259,7 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio
 
                        if (this.map.readonly !== true) {
                                ui.addValidator(nameEl, 'uciname', true, function(v) {
-                                       var button = document.querySelector('.cbi-section-create > .cbi-button-add');
+                                       var button = createEl.querySelector('.cbi-section-create > .cbi-button-add');
                                        if (v !== '') {
                                                button.disabled = null;
                                                return true;